package com.example.activitys;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import com.example.activitys.IllegalStopDrivingTakePhoto.priviewCallBack;
import com.example.getRetrnValue.PullStopCarUploadRetrun;
import com.example.getinfo.GetDrivinglicenseInfo;
import com.example.tracontroller.CameraDecod;
import com.example.tracontroller.DriverSaveToSQL;
import com.example.tracontroller.QuerySQLData;
import com.example.tracontroller.R;
import com.example.tracontroller.R.layout;
import com.example.tracontroller.R.menu;
import com.example.util.Base64;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.zijunlin.Zxing.Demo.camera.CameraManager;
import com.zijunlin.Zxing.Demo.decoding.CaptureActivityHandler;
import com.zijunlin.Zxing.Demo.decoding.InactivityTimer;
import com.zijunlin.Zxing.Demo.view.ViewfinderView;

import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.app.Activity;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ImageFormat;
import android.graphics.Rect;
import android.graphics.YuvImage;
import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.util.Log;
import android.view.Menu;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.SurfaceHolder.Callback;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class InputDrivinglicenseActivity extends Activity
{
	private Camera mCamera;
	private EditText inputed;
	private Button query;
	private Button CameraScan;
	private SurfaceView mCameraSee;
	private SurfaceHolder mHolder;
    public static  Handler handler2;
    private Button autoScan;
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_input_drivinglicense);
		
		findViews();

		inputed.setText("3770003320368");
			
		query.setOnClickListener(new OnClickListener()
		{

			@Override
			public void onClick(View arg0)
			{
				// TODO Auto-generated method stub

				List getedData = GetDrivinglicenseInfo
						.getDrivinglicenseInfo(inputed.getText().toString());
				Intent intent = new Intent();
				intent.setClass(InputDrivinglicenseActivity.this,
						SeeDrivinglicenseActivity.class);
				ArrayList data = new ArrayList();
				data.add(getedData);
				intent.putExtra("data", data);
				startActivity(intent);

			}
		});
		autoScan.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent bintent = new Intent(InputDrivinglicenseActivity.this, CameraDecod.class);

//				
				startActivityForResult(bintent,0); 
			}
		});
	}
	

	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		switch (resultCode) { 
		case RESULT_OK:
		Bundle b=data.getExtras(); 
		String str=b.getString("code");
		System.out.println("code!!!!"+str);
		inputed.setText(str);
		   break;
		default:
		break;
		}
		}
	private void findViews()
	{
		// TODO Auto-generated method stub
		autoScan = (Button) findViewById(R.id.autoscan);
		inputed = (EditText) findViewById(R.id.inputbox);
		query = (Button) findViewById(R.id.querybarcode);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_input_drivinglicense, menu);

		return true;
	}

}
